home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / mac / developm / source / fngsrc.sit / Finger 1.3.5 Source / Common Units / PrefsGlobals.unit < prev   
Encoding:
Text File  |  1992-02-24  |  2.2 KB  |  109 lines

  1. unit PrefsGlobals;
  2.  
  3. { This code is part of the Finger/Fingerd source code, written in THINK Pascal 4 }
  4. { Copyright 1991-1992 Peter N Lewis }
  5. { If you use this code, you must give me credit in your about box and documentation }
  6.  
  7. interface
  8.  
  9.     const
  10.         prefs_version = $010;
  11.         prefsCreator = 'PnLF';
  12.         prefsType = 'PnLF';
  13.         prefsResType = 'PREF';
  14.         prefsResID = 128;
  15.         prefsStrhResID = 128;
  16.         prefsNameStrhIndex = 1;
  17.         prefsFinderCommentStrhIndex = 2;
  18.  
  19.     type
  20.     { DONT REORDER THIS RECORD OR THESE TYPES! }
  21.         prefsRecord = record
  22.                 version: integer;
  23.                 showIP: boolean;
  24.                 autoopen: boolean;
  25.                 dummy: array[3..15] of boolean;
  26.                 plan_enabled: boolean;  { plan enabled }
  27.                 plan_dirID: longInt;
  28.                 plan_vrn: integer;   { In memory only }
  29.                 plan_CrDate: longInt;   { volume creation date, on disk only }
  30.                 plan_volume: str63;  { volume name, on disk only }
  31.                 plan_name: str63;  { file name }
  32.             end;
  33.  
  34.     var
  35.         prefs: prefsRecord;
  36.  
  37.     procedure SegmentPrefs;
  38.     procedure GetPrefPlan;
  39.     procedure ValidatePrefs (var prefs: prefsRecord);
  40.  
  41. implementation
  42.  
  43.     uses
  44.         MyUtils;
  45.  
  46. {$S Prefs}
  47.     procedure SegmentPrefs;
  48.     begin
  49.     end;
  50.  
  51. {$S Prefs}
  52.     procedure GetPrefPlan;
  53.         var
  54.             oe: OSErr;
  55.             vrn: integer;
  56.             crdate: longInt;
  57.             pb: HParamBlockRec;
  58.     begin
  59.         with prefs do begin
  60.             if (plan_volume = '') or (plan_dirID = -1) or (plan_name = '') then
  61.                 oe := -1
  62.             else begin
  63.                 vrn := 0;
  64.                 oe := GetVolInfo(plan_volume, vrn, -1, crdate);
  65.                 if (oe = noErr) and (crdate <> plan_crdate) then
  66.                     oe := -1;
  67.                 if oe = noErr then begin
  68.                     with pb do begin
  69.                         ioNamePtr := @plan_name;
  70.                         ioVRefNum := vrn;
  71.                         ioDirID := plan_dirID;
  72.                         ioFDirIndex := 0;
  73.                     end;
  74.                     oe := PBHGetFInfo(@pb, false);
  75.                 end;
  76.             end;
  77.             if oe = noErr then begin
  78.                 plan_vrn := vrn;
  79.             end
  80.             else begin
  81.                 plan_enabled := false;
  82.                 plan_vrn := 0;
  83.                 plan_volume := '';
  84.                 plan_dirID := -1;
  85.                 plan_name := '';
  86.             end;
  87.         end;
  88.     end;
  89.  
  90. {$S Prefs}
  91.     procedure ValidatePrefs (var prefs: prefsRecord);
  92.         var
  93.             i: integer;
  94.     begin
  95.         with prefs do begin
  96.             if version <> prefs_version then begin
  97.                 version := prefs_version;
  98.                 showIP := false;
  99.                 autoopen := false;
  100.                 plan_enabled := false;
  101.                 plan_dirID := -1;
  102.             end;
  103.             for i := 3 to 15 do
  104.                 dummy[i] := false;
  105.         end;
  106.         GetPrefPlan;
  107.     end;
  108.  
  109. end.